﻿using MDT.LifeSewagePlatform.Conmmon;
using MDT.LifeSewagePlatform.Entity;
using MDT.LifeSewagePlatform.InterfaceService;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.ServiceInstance.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/alaramrule")]
    [ApiController]
    [Authorize]
    public class AlaramRuleController : BaseController
    {
        /// <summary>
        /// 
        /// </summary>
        [Autowired]
        protected IAlaramRuleService alaramRuleService { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public AlaramRuleController()
        {

        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="alaramRuleCreateDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseMessage> AddAsync([FromForm] AlaramRuleCreateDto alaramRuleCreateDto)
        {
            return await alaramRuleService.AddAsync(alaramRuleCreateDto, GetUserID());
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="alaramRuleCreateDto"></param>
        /// <returns></returns>
        [HttpPut("{Id}")]
        public async Task<BaseMessage> UpdateAsync(int Id, [FromForm] AlaramRuleCreateDto alaramRuleCreateDto)
        {
            return await alaramRuleService.UpdateAsync(Id,alaramRuleCreateDto, GetUserID());
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>

        [HttpDelete("{Id}")]
        public async Task<BaseMessage> DeleteAsync(int Id)
        {
            return await alaramRuleService.DeleteAsync(Id);
        }
        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete("soft/{Id}")]
        public async Task<BaseMessage> SoftDeleteAsync(int Id)
        {
            return await alaramRuleService.SoftDeleteAsync(Id,GetUserID());
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        [HttpGet()]
        public async Task<BaseMessage> GetAsync([FromQuery] AlaramRuleParameter Params)
        {
            return await alaramRuleService.GetRulesAsync(Params);
        }

    }
}
